package com.example.newstest.until;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;


import com.example.newstest.news.fragment.NewsFristFragment;
import com.example.newstest.news.fragment.NewsSecondFragment;

import java.util.Map;

/**
 * Created by Administrator on 2017/1/14.
 */
public class PagerFragmentAdapter extends FragmentPagerAdapter {
    private String[] titles;
    public PagerFragmentAdapter(FragmentManager fm,String[] titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return new NewsFristFragment();
            }else{
                return NewsSecondFragment.newInstance(titles[position]);
            }
        }
    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
